package com.cn.yz.springboot.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cn.yz.springboot.util.httpcilent.HttpRequest;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

@RestController
public class HttpController {

	@RequestMapping("httpClient/sendGet")
	public String sendGet(){
		String get =HttpRequest.sendGet("http://localhost:8080/api/query_order", "idCard=&orderDate=&orderNodeId=&orderChannel=&start=0&limit=2");
		return get;
	}
	
	@RequestMapping("httpClient/sendPost")
	public String sendPost() throws Exception{
		//String param = "{\"id\":\"3\",\"node_id\":100,\"node_name\":\"删除\",\"order_num\":100}";
		Map map = new HashMap();
		map.put("id", "3");
		map.put("node_id", "19");
		map.put("node_name", Math.random());
		map.put("order_num", 100);
		ObjectMapper mapper = new ObjectMapper(); 
		String param = mapper.writeValueAsString(map);
        String post = HttpRequest.sendPost("http://localhost:8080/api/update_node", param);
		return post;
	}
}
